home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / var / lib / dpkg / info / man-db.postinst < prev    next >
Encoding:
Text File  |  2011-01-02  |  3.7 KB  |  122 lines

  1. #!/bin/sh -e
  2.  
  3. . /usr/share/debconf/confmodule
  4. db_version 2.0
  5.  
  6. run_mandb () {
  7.     db_get man-db/auto-update
  8.     [ "$RET" = true ] || return 0
  9.     # start-stop-daemon isn't available when running from debootstrap.
  10.     perl -e '@pwd = getpwnam("man"); $( = $) = $pwd[3]; $< = $> = $pwd[2];
  11.          exec "/usr/bin/mandb", @ARGV' -- "$@" || true
  12. }
  13.  
  14. if [ "$1" = triggered ]; then
  15.     # We don't print a status message here, as dpkg already said
  16.     # "Processing triggers for man-db ...".
  17.     run_mandb -pq
  18.     exit 0
  19. fi
  20.  
  21. [ "$1" = configure ] || exit 0
  22.  
  23. oldcatdir=/var/catman
  24. catdir=/var/cache/man
  25. maybesetuid='man mandb'
  26. conffile=/etc/manpath.config
  27.  
  28. db_get man-db/install-setuid
  29.  
  30. # Sorry about this, but #98224 is right - statoverrides don't work as
  31. # cleanly as I'd hoped here. I'm going to have to carry around some cruft
  32. # for a while.
  33. for x in $maybesetuid; do
  34.     if dpkg --compare-versions "$2" eq 2.3.18-4 && \
  35.         [ "`dpkg-statoverride --list /usr/lib/man-db/$x`" = \
  36.           "man root 4755 /usr/lib/man-db/$x" ]; then
  37.     dpkg-statoverride --remove /usr/lib/man-db/$x
  38.     fi
  39. done
  40.  
  41. if [ "$RET" = true ]; then
  42.     # man and mandb are to be installed setuid man.
  43.     owner=man:root
  44.     mode=4755
  45. else
  46.     # man and mandb are not to be installed setuid.
  47.     owner=root:root
  48.     mode=0755
  49. fi
  50.  
  51. for x in $maybesetuid; do
  52.     # No statoverrides available or none exist for us ...
  53.     if [ ! -x /usr/sbin/dpkg-statoverride ] || \
  54.         ! dpkg-statoverride --list /usr/bin/$x >/dev/null; then
  55.     chown $owner /usr/bin/$x || true
  56.     chmod $mode  /usr/bin/$x
  57.     fi
  58. done
  59.  
  60. if [ -e /etc/cron.daily/man.moved-by-preinst ]; then
  61.     rm /etc/cron.daily/man.moved-by-preinst
  62. fi
  63. if [ -e /etc/cron.weekly/catman.moved-by-preinst ]; then
  64.     rm /etc/cron.weekly/catman.moved-by-preinst
  65. fi
  66.  
  67. if dpkg --compare-versions "$2" lt 2.3.18; then
  68.     # /usr/local/man now mapped to /var/cache/man/oldlocal
  69.     if [ -d $catdir/local ] && [ ! -d $catdir/oldlocal ]; then
  70.     mv -f $catdir/local $catdir/oldlocal
  71.     fi
  72. fi
  73.  
  74. if [ -d $catdir ]; then
  75.     # Catdirs sometimes used to be created with the wrong permissions.
  76.     if dpkg --compare-versions "$2" lt 2.3.20-4; then
  77.     chown -R man /var/cache/man || true
  78.     fi
  79. else
  80.     # Old packages removed catpages on upgrade. The preinst hack should have
  81.     # avoided this, but let's be sure.
  82.     install -d -o man -g root -m 02755 $catdir
  83. fi
  84.  
  85. build_db=0
  86.  
  87. if dpkg --compare-versions "$2" lt 2.3.16 || \
  88.    ([ ! -f $catdir/index.db ] && [ ! -f $catdir/index.bt ]); then
  89.     # All versions before 2.3.17.1-1 removed cat page hierarchies on
  90.     # upgrade. Since then a preinst hack means upgrades from 2.3.16 or later
  91.     # won't do this, but the hack is nasty enough that I don't want to
  92.     # extend it back beyond then. Thus, we need to build the database from
  93.     # scratch on old upgrades. This also covers fresh installs.
  94.     build_db=1
  95. elif dpkg --compare-versions "$2" lt 2.4.2-1; then
  96.     # At 2.3.17.1-5, the database version number changed to 2.3.2.
  97.     # At 2.4.0-1, the database version number changed to 2.4.1 and we
  98.     # moved from libdb2 to libdb3.
  99.     # At 2.4.2-1, we moved from libdb3 to libgdbm3.
  100.     build_db=1
  101.  
  102.     # Clean up old btree databases from before 2.4.2-1. They're useless now.
  103.     find /var/cache/man -name index.bt -print0 | xargs -0r rm -f
  104. fi
  105.  
  106. if [ $build_db -eq 1 ]; then
  107.     # Chances are we're being run from debootstrap, which will have problems
  108.     # if mandb runs backgrounded for too long (bug #100616).
  109.     echo "Building database of manual pages ..." >&2
  110.     run_mandb -cq
  111. else
  112.     # Otherwise, just update the database in the foreground. It's unlikely
  113.     # to take very long, and configuration needs to cover everything that
  114.     # happens when we're triggered.
  115.     echo "Updating database of manual pages ..." >&2
  116.     run_mandb -pq
  117. fi
  118.  
  119.  
  120.  
  121. exit 0
  122.